fix(@angular/ssr): support custom headers in redirect responses [20]#32779
Conversation
Updated the INVALID_PREFIX_REGEX to ensure that prefixes starting with a backslash are considered invalid. Previously, only multiple slashes or dot segments were explicitly disallowed at the start. Also updated the associated validation error message and unit tests to reflect this change.
There was a problem hiding this comment.
Code Review
This pull request refactors the createRedirectResponse function into its own utility file packages/angular/ssr/src/utils/redirect.ts and enhances it to support custom headers in redirect responses. The changes are well-structured and include corresponding updates to call sites and new tests. I've found a small issue with how the Vary header is being constructed which could lead to duplicate values. My suggestion addresses this to make the logic more robust.
Updates createRedirectResponse to accept an optional Record<string, string> of headers, allowing custom headers to be merged into the redirect response. The Location and Vary: X-Forwarded-Prefix headers are automatically set to ensure correct routing and proxy behavior. AngularServerApp now passes relevant headers from the matched route or response context when creating a redirect.
dc703c5 to
c062207
Compare
Refactors the `createRedirectResponse` function to use a `Set` for constructing the `Vary` header. This ensures that `X-Forwarded-Prefix` is always present exactly once, and that existing `Vary` values from provided headers are correctly parsed, deduplicated, and preserved. Updates the associated unit tests to reflect the new header order and verify the deduplication logic.
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.